$(document).ready(function(){
    loadTable();
    $(".footable").footable();
});

function loadTable() {
    $.ajax({
        url : '/user/check/list/1/10000',
        type : 'get',
        async : false,
        success : function (data) {
            console.log(data)

            if(data.data.totalRecords > 0){
                for(var i in data.data.records){
                    var obj = data.data.records[i];

                    var html = '<tr class="footable-even" style="display: table-row;">';
                    html += '<td>' + obj.nickName + '</td>';
                    html += '<td>' + obj.realName + '</td>';
                    html += '<td>' + obj.phone + '</td>';
                    html += '<td>' + (parseInt(obj.level) === 0 ? '非会员' : '会员') + '</td>';
                    html += '<td><a onclick="checkUser(' + obj.id + ')"><i class="fa fa-check text-navy"></i> 通过</a></td>';
                    html += '</tr>';

                    $('#tb').append(html);
                }
            }
        }
    })
}

function checkUser(id) {
    $.ajax({
        url : '/user/check/' + id + '',
        type : 'put',
        success : function (d) {
            if(d.success){
                window.location.reload();
            }
        }
    })
}

function reloadPage() {
    window.location.reload();
}